{extend name="public:layout" /}
{block name="title"}商品分组{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> 商品分组列表</li>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <div class="pull-left">
                    <button class="btn btn-white" type="button" onclick="updateOrder()">
                        <i class="fa fa-sort"></i> 更新排序
                    </button>
                    <a type="button" href="{:url('add')}"  class="btn btn-primary">添加商品分组</a>
                    <a class="btn btn-primary" href="{:url('updateCache')}">
                        <i class="fa"></i>&nbsp;更新缓存
                    </a>
                </div>
                <div class="clearfix"></div>
            </div>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="80">排序</th>
                    <th >分组名</th>
                    <th width="200">操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="catList" id="vo"}
                <tr>
                    <td>
                        <input type="text" class="form-control cat-order"
                               name="list_order[{$vo.cid}]" value="{$vo['cat_order']}"/>
                    </td>
                    <td >{$vo._name}</td>
                    <td>
                        <a href="{:url('add',['pid'=>$vo['cid']])}">添加下级分组</a>
                        <a href="{:url('edit',['cid'=>$vo['cid']])}">修改</a>
                        <a href="javascript:;" onclick="doAction(this);"
                           data-msg="确认删除吗？" data-url="{:url('del')}" data-params="cid={$vo.cid}">删除</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
    //更新排序
    function updateOrder() {
        if ($(".cat-order").length > 0) {
            var data = $(".cat-order").serialize();
            var url = "{:url('updateOrder')}";
            getAjax(url, data, function (data) {
                rePage();
            });
        }
    }
</script>
{/block}
